package com.ruoyi.gwc.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SnowFlakeIDGenerator;
import com.ruoyi.gwc.domain.TApprovalRepair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.gwc.mapper.TRepairManagementMapper;
import com.ruoyi.gwc.domain.TRepairManagement;
import com.ruoyi.gwc.service.ITRepairManagementService;

import static com.ruoyi.common.utils.SecurityUtils.getUsername;

/**
 * 维修管理Service业务层处理
 * 
 * @author wp
 * @date 2024-12-13
 */
@Service
public class TRepairManagementServiceImpl extends ServiceImpl<TRepairManagementMapper, TRepairManagement> implements ITRepairManagementService
{
    @Autowired
    private TRepairManagementMapper tRepairManagementMapper;

    /**
     * 查询维修管理
     * 
     * @param repairId 维修管理主键
     * @return 维修管理
     */
    @Override
    public TRepairManagement selectTRepairManagementByRepairId(Long repairId)
    {
        return tRepairManagementMapper.selectTRepairManagementByRepairId(repairId);
    }

    /**
     * 查询维修管理列表
     * 
     * @param tRepairManagement 维修管理
     * @return 维修管理
     */
    @Override
    public List<TRepairManagement> selectTRepairManagementList(TRepairManagement tRepairManagement)
    {
        return tRepairManagementMapper.selectTRepairManagementList(tRepairManagement);
    }

    @Override
    public List<TRepairManagement> getApprovalRepairList(TApprovalRepair approvalRepair)
    {
        return tRepairManagementMapper.getApprovalRepairList(approvalRepair);
    }

    /**
     * 新增维修管理
     * 
     * @param tRepairManagement 维修管理
     * @return 结果
     */
    @Override
    public int insertTRepairManagement(TRepairManagement tRepairManagement)
    {
        tRepairManagement.setCreateTime(DateUtils.getNowDate());
        tRepairManagement.setCreateBy(getUsername());
        tRepairManagement.setRepairId(SnowFlakeIDGenerator.getInstance().nextId());
        return tRepairManagementMapper.insertTRepairManagement(tRepairManagement);
    }

    /**
     * 修改维修管理
     * 
     * @param tRepairManagement 维修管理
     * @return 结果
     */
    @Override
    public int updateTRepairManagement(TRepairManagement tRepairManagement)
    {
        tRepairManagement.setUpdateTime(DateUtils.getNowDate());
        tRepairManagement.setUpdateBy(getUsername());
        return tRepairManagementMapper.updateTRepairManagement(tRepairManagement);
    }

    /**
     * 批量删除维修管理
     * 
     * @param repairIds 需要删除的维修管理主键
     * @return 结果
     */
    @Override
    public int deleteTRepairManagementByRepairIds(Long[] repairIds)
    {
        return tRepairManagementMapper.deleteTRepairManagementByRepairIds(repairIds);
    }

    /**
     * 删除维修管理信息
     * 
     * @param repairId 维修管理主键
     * @return 结果
     */
    @Override
    public int deleteTRepairManagementByRepairId(Long repairId)
    {
        return tRepairManagementMapper.deleteTRepairManagementByRepairId(repairId);
    }
}
